﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LotteryVote.Utility;

namespace LotteryVote.Entity
{
    /// <summary>
    /// 分成信息
    /// </summary>
    public class ShareRateInfo
    {
        /// <summary>
        /// 公司分成
        /// </summary>
        /// <value>
        /// The company share rate.
        /// </value>
        public ShareRateItem CompanyShareRate { get; set; }
        /// <summary>
        /// 高级代理分成
        /// </summary>
        /// <value>
        /// The super share rate.
        /// </value>
        public ShareRateItem SuperShareRate { get; set; }
        /// <summary>
        /// 总代分成
        /// </summary>
        /// <value>
        /// The master share rate.
        /// </value>
        public ShareRateItem MasterShareRate { get; set; }
        /// <summary>
        /// 代理分成
        /// </summary>
        /// <value>
        /// The agent share rate.
        /// </value>
        public ShareRateItem AgentShareRate { get; set; }
    }

    public class ShareRateItem
    {
        private double _shareRate;
        public User User { get; set; }
        /// <summary>
        /// 分成数（小数）.
        /// </summary>
        /// <value>
        /// The share rate.
        /// </value>
        public double ShareRate { get; set; }
        /// <summary>
        /// 分成百分比值.
        /// </summary>
        public double ShareRatePercent
        {
            get
            {
                if (_shareRate == 0)
                    _shareRate = (ShareRate * 100).AccurateDecimalPointTwo();
                return _shareRate;
            }
        }

        public ShareRateItem(User user, double shareRate)
        {
            this.User = user;
            this.ShareRate = shareRate;
        }
    }
}
